<?php

namespace app\admin\controller;


use app\admin\service\UavService;
use think\Request;

class Uav extends Backend
{
    /**
     * @var UavService
     */
    protected $service;

    protected function initialize()
    {
        parent::initialize();
        $this->service = new UavService();
    }

    public function getList(Request $request)
    {
        $all = $request->param('all', 0);
        $data = $this->service->lists($all);
        $this->jsonReturn($data);
    }

    public function find(Request $request)
    {
        $data = $this->service->info($request->param('id'));
        $this->jsonReturn(['code' => 0, 'msg' => 'success', 'data' => $data]);
    }

    public function save(Request $request)
    {
        $param = $request->except(['create_user', 'create_time', 'update_user', 'update_time']);
        $this->service->save($param, $this->userId);
        $this->jsonReturn(['code' => 0, 'msg' => 'success']);
    }

    public function delete()
    {
        $id = $this->request->param('id');
        $this->service->delete($id);
        $this->jsonReturn(message());
    }
}
